package cn.acewill.yxd.yunxundian.ui.sign.Presenter;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.xutils.ex.DbException;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import cn.acewill.yxd.yunxundian.model.Employee;
import cn.acewill.yxd.yunxundian.model.RMain;
import cn.acewill.yxd.yunxundian.model.tempLostRR;
import cn.acewill.yxd.yunxundian.pubClass.pubClass;
import cn.acewill.yxd.yunxundian.ui.sign.Contract.BackUpLoadView;
import cn.acewill.yxd.yunxundian.ui.sign.Contract.BackUpPresenter;
import cn.acewill.yxd.yunxundian.ui.sign.Contract.MEvaLoadListener;
import cn.acewill.yxd.yunxundian.ui.sign.Contract.MEvaluationView;

/**
 * Created by xxx on 2018/1/19.
 */

public class BackUpPresenterIml implements BackUpPresenter,MEvaLoadListener{
    private BackUpLoadView loadView;
    private BackUpModelIml backUpModelIml;
    public BackUpPresenterIml(BackUpLoadView loadView){
        this.loadView = loadView;
        backUpModelIml = new BackUpModelIml();
    }

    @Override
    public void loadToManList(int schId, BackUpLoadView BackUpLoadView) {
        if (loadView!=null){
            backUpModelIml.getShopTodoEmpList(schId,this);
            loadView.showLoadingView();
        }
    }

    @Override
    public void onRequestSuccess(String result) {
        String[] array = result.split("\\|");
        if(array[0].equals("200")){
            Gson gson=new Gson();
            Type typeList=new TypeToken<ArrayList<Employee>>(){}.getType();
            List<Employee> emp=gson.fromJson(pubClass.convertToArrayJson(result),typeList);
            loadView.hideLoadingView();
            loadView.updateSpinner(emp);
        }else{
            loadView.requestErro();
            loadView.hideLoadingView();
        }
    }

    @Override
    public void onRequestEro() {
        loadView.requestErro();
        loadView.hideLoadingView();
    }

//    public void modifLostRR(tempLostRR rr, int schId, RMain.TablesBean.RowsBean.Q2Bean q2Bean,boolean isCheck){
//        if (rr!=null){
//            int _id = rr.get_ID();
//            rr = new tempLostRR(_id,"",isCheck);
//        }else {
//
//        }
//    }
}
